# 导包
import time
from appium import webdriver
from appium.options.android import UiAutomator2Options
from appium.webdriver.common.appiumby import By
from selenium.webdriver.ie.webdriver import WebDriver
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
# 配置移动端设备信息
des_caps = {
    "platformName": "Android",  # 移动端系统平台
    "platformVersion": "12",  # 平台对应版本
    "deviceName": "mumu",  # 设备名称（可以随便写）
    "appPackage": "com.netease.yanxuan",  # 包名
    "appActivity": ".SplashActivityDefault"  # Activity页面名
}
# 初始化设备配置信息
option = UiAutomator2Options().load_capabilities(des_caps)
# 创建驱动对象
driver = webdriver.Remote("http://127.0.0.1:4723/wd/hub", options=option)
time.sleep(2)
driver.find_element(By.XPATH,'//android.widget.Button[@resource-id="com.netease.yanxuan:id/btn_alert_positive"]').click()
time.sleep(1)

num4=WebDriverWait(driver,10).until(EC.visibility_of_element_located((By.XPATH,'//android.widget.ImageView[@resource-id="com.netease.yanxuan:id/view_bg"]')))
num4.click()

ele=WebDriverWait(driver,10).until(EC.visibility_of_element_located((By.XPATH,'//*[@text="个人"]')))
ele.click()
num=WebDriverWait(driver,10).until(EC.visibility_of_element_located((By.XPATH,'(//android.widget.ImageView[@resource-id="com.netease.yanxuan:id/img_icon"])[2]')))
num.click()
num1=WebDriverWait(driver,10).until(EC.visibility_of_element_located((By.XPATH,'//android.widget.TextView[@resource-id="com.netease.yanxuan:id/newOtherLoginTypes"]')))
num1.click()
num2=WebDriverWait(driver,10).until(EC.visibility_of_element_located((By.XPATH,'//android.widget.CheckBox[@resource-id="com.netease.yanxuan:id/check_box"]')))
num2.click()
num3=WebDriverWait(driver,10).until(EC.visibility_of_element_located((By.XPATH,'(//android.widget.ImageView[@resource-id="com.netease.yanxuan:id/img_icon"])[4]')))
num3.click()
num5=WebDriverWait(driver,10).until(EC.visibility_of_element_located((By.XPATH,'//android.widget.AutoCompleteTextView[@resource-id="com.netease.yanxuan:id/account_edit"]')))
num5.send_keys('m17735097747@163.com')
num6=WebDriverWait(driver,10).until(EC.visibility_of_element_located((By.XPATH,'//android.widget.EditText[@resource-id="com.netease.yanxuan:id/password_edit"]')))
num6.send_keys('Liang1314520')
num7=WebDriverWait(driver,10).until(EC.visibility_of_element_located((By.XPATH,'//android.widget.TextView[@resource-id="com.netease.yanxuan:id/btn_login_content"]')))
num7.click()

num9=WebDriverWait(driver,10).until(EC.visibility_of_element_located((By.XPATH,'//android.widget.TextView[@resource-id="com.netease.yanxuan:id/order_tag" and @text="全部订单"]'))).text
print(num9)
# assert '订单' in num9


# 暂停3秒
time.sleep(3)
# 关闭驱动
driver.quit()